package Forms;

import App.DCMain;
import Forms.Options;
import Forms.Editor;
import Core.ControlImage;
import Core.*;
import Controls.*;

public class MainMenu extends Form
{

	private Button calc,  graph,  exit,  opt,  rendertest;


	public MainMenu()
	{
		super(Form.HEAD);

		setWindowText(GM.FORM_CAPTION, "Main menu");

		body.h_border = 3;

		calc = new Button("Calculation", body);
		graph = new Button("Graphs", body);
		opt = new Button("Options", body);
		exit = new Button("Exit", body);
		rendertest = new Button("Render test", body);

		ControlImage arr = new ControlImage("/contextArrow.png", ALIGN.RIGHT);
		calc.addImage(arr);
		graph.addImage(arr);

		opt.addImage(arr);
		exit.addImage(ControlImage.BACK_R);

		body.addControl(new Spacer());
		body.setHotControl(body.addControl(calc), 1);
		body.setHotControl(body.addControl(graph), 2);
		body.setHotControl(body.addControl(opt), 3);
		body.setHotControl(body.addControl(exit), Key.STAR_KEY);
		body.addControl(new Spacer());

		//body.addControl(rendertest);

		body.select(Control.UNDER);
	}

	public void onEvent(int event, Object param)
	{
		if (event != GM.CONTROL_RELEASED)
		{
			return;
		}

		if (param == exit)
		{
			DCMain.instance.exitMIDlet();
		}
		else if (param == calc)
		{
			Editor e = new Editor();
		}
		else if (param == opt)
		{
			Options o = new Options();
		}
		else if(param == graph)
		{
			GraphEditor g = new GraphEditor();
		}
	}
}
